package views
{
	import assists.media.SoundMedia;
	import assists.resource.ResourceLoaderData;
	
	import inerface.IMediaPanel;
	
	import main.ViewSubBase;
	
	import panel.media.MediaPanel;
	
	public class MediaView extends ViewSubBase
	{
		public var soundUrl:String = "";
		private var _panel:IMediaPanel;
		private var _delayFunc:Function;
		private var _delayInfo:Object;
		public var soundName:String;
		public function MediaView()
		{
			super();
		}
		
		override public function show():void
		{
			render();
		}
		
		override protected function render():void
		{
			if(_panel)
			{
				_panel.soundMedia.soundName = soundName;
				_panel.playSound(soundUrl);
				return;
			}
			_panel = new MediaPanel();
			_panel.init(view.layout.stage,view.resourceLoader,lang);
			_panel.soundMedia.soundName = soundName;
			_panel.playSound(soundUrl);
			if(_delayFunc != null)
			{
			_delayFunc();
			}
//			this.addView(_panel);
//			view.guide.upAndDownVisible(true,false);
//			if(_delayFunc != null)
//			{
//				_delayFunc(_delayInfo.showStr,_delayInfo.speed,_delayInfo.showWid,_delayInfo.showHei);
//			}
		}
		
		public function playTextScroll(showStr:String,speed:Number,showWid:int,showHei:int):void
		{
			if(!_panel)
			{
				_delayInfo = {};
				_delayInfo.showStr = showStr;
				_delayInfo.speed = speed;
				_delayInfo.showWid = showWid;
				_delayInfo.showHei = showHei;
				_delayFunc = playTextScroll;
			}else
			{
			_panel.startScrollText(showStr,speed,showWid,showHei);
			}
		}
		
		public function get soundMedia():SoundMedia
		{
			return _panel.soundMedia;
		}
		
		override public function clear():void
		{
			_delayFunc = null;
			_panel.clear();
		}
		
		public function set onDelayFunc(value:Function):void
		{
			_delayFunc = value;
		}
		
	}
}